<!DOCTYPE html>
<title>Subresource loading using relative URLs in the 'resources' attribute</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<body>
  <link
  id="bundle"
  rel="webbundle"
  href="../resources/wbn/hello.wbn"
  resources="/loading/wbn/resources/hello/script.js"/>
  <script id="script" src="/loading/wbn/resources/hello/script.js"></script>

  <script>
    // When preload scanner encounters a <link> element with a webbundle, it must not
    // preload a request for the webbundle itself and any subresources mentioned in the
    // 'resources' attribute.
    // This test loads a simple hello.wbn bundle and script.js served from the bundle,
    // and checks that both hello.wbn and script.js were not preloaded.
    const onLoadPromise = new Promise((resolve) => {
      window.addEventListener('load', resolve, false);
    });

    promise_test(async () => {
      await onLoadPromise;

      if (window.internals) {
        assert_false(internals.isPreloaded(script.src));
        assert_false(internals.isPreloaded(bundle.href));
        assert_equals(script_result, 'loaded from webbundle');
      }
    }, "A subresource script.js should be loaded from WebBundle using the relative URL.");
  </script>
</body>